/**
 * 血骑士装备配置
 * 这个文件展示了如何用新的配置系统替代复杂的Excel配置
 */

import { EquipmentTemplate, ConfigCollection } from '../types/ConfigTypes';

/**
 * 血骑士武器配置
 */
export const bloodKnightWeapons: EquipmentTemplate[] = [
    {
        id: "blood_knight_sword_001",
        name: "嗜血之剑",
        sys: "生物本质",
        type: "血族",
        job: "血骑士",
        solt: "武器",
        icon: "sword_blood",
        emoji: "🗡️",
        desc: "饮血而生的邪恶之剑，每次攻击都能汲取敌人的生命力",
        source: "血族遗迹",
        
        quality: {
            min: 2, // 绿色起步
            max: 5, // 最高橙色
            weights: [40, 30, 20, 10] // 各品质权重分布（对应品质2,3,4,5）
        },
        
        baseAttributes: [
            {
                key: "魔法攻击",
                min: 15,
                max: 25,
                growthType: "linear",
                qualityMultiplier: 1.2
            },
            {
                key: "最大生命值",
                min: 40,
                max: 60,
                growthType: "linear",
                qualityMultiplier: 1.1
            },
            {
                key: "吸血",
                min: 5,
                max: 10,
                growthType: "exponential"
            }
        ],
        
        skillPools: {
            // 固有技能 - 必定拥有
            inherent: [
                {
                    skillId: "SOUL_DRAIN",
                    reName: "灵魂吸取",
                    desc: "对目标造成魔法伤害并回复自身生命值",
                    maxLevel: 10,
                    type: "active"
                }
            ],
            
            // 可附魔技能池
            enchantable: [
                {
                    skill: {
                        skillId: "BLOOD_CONVERT",
                        reName: "鲜血转换",
                        desc: "消耗生命值大幅提升下次攻击伤害",
                        maxLevel: 5,
                        type: "active"
                    },
                    weight: 100,
                    maxCount: 1
                },
                {
                    skill: {
                        skillId: "VAMPIRE_AURA",
                        reName: "吸血光环",
                        desc: "使队友攻击时回复少量生命值",
                        maxLevel: 8,
                        type: "aura"
                    },
                    weight: 80,
                    conditions: {
                        minLevel: 3
                    }
                },
                {
                    skill: {
                        skillId: "BLOOD_SHIELD",
                        reName: "血之护盾",
                        desc: "受到伤害时有概率获得护盾",
                        maxLevel: 6,
                        type: "passive"
                    },
                    weight: 60,
                    conditions: {
                        requiredTalent: "vampire_lord"
                    }
                }
            ],
            
            // 专属技能 - 特殊解锁
            exclusive: [
                {
                    skill: {
                        skillId: "BLOOD_LORD_AWAKEN",
                        reName: "血主觉醒",
                        desc: "短时间内释放血族的真正力量，大幅提升所有属性",
                        maxLevel: 1,
                        type: "active"
                    },
                    unlock: {
                        type: "quest",
                        requirement: "complete_blood_heritage_quest",
                        description: "完成血族传承任务线"
                    }
                }
            ]
        },
        
        creator: "system",
        version: "1.0.0",
        enabled: true,
        tags: ["血族", "武器", "吸血", "高级"]
    },
    
    {
        id: "blood_knight_armor_001", 
        name: "血纹战甲",
        sys: "生物本质",
        type: "血族", 
        job: "血骑士",
        solt: "护甲",
        icon: "armor_blood",
        emoji: "🥼",
        desc: "刻有古老血族符文的战甲，能够增强穿戴者的血族能力",
        
        quality: {
            min: 1,
            max: 4,
            weights: [30, 35, 25, 10]
        },
        
        baseAttributes: [
            {
                key: "最大生命值",
                min: 80,
                max: 120,
                qualityMultiplier: 1.3
            },
            {
                key: "物理防御",
                min: 20,
                max: 35
            },
            {
                key: "魔法防御", 
                min: 15,
                max: 25
            }
        ],
        
        skillPools: {
            inherent: [
                {
                    skillId: "BLOOD_ARMOR",
                    reName: "血之护甲",
                    desc: "生命值越低，防御力越高",
                    maxLevel: 8,
                    type: "passive"
                }
            ],
            
            enchantable: [
                {
                    skill: {
                        skillId: "REGENERATION",
                        reName: "血族再生",
                        desc: "每回合回复少量生命值",
                        maxLevel: 10,
                        type: "passive"
                    },
                    weight: 120
                },
                {
                    skill: {
                        skillId: "BLOOD_BURST",
                        reName: "血爆反击",
                        desc: "受到致命伤害时对周围敌人造成伤害",
                        maxLevel: 5,
                        type: "passive"
                    },
                    weight: 60,
                    conditions: {
                        minLevel: 5
                    }
                }
            ]
        },
        
        enabled: true,
        tags: ["血族", "护甲", "防御", "再生"]
    }
];

/**
 * 血骑士装备配置集合
 */
export const BloodKnightEquipmentCollection: ConfigCollection<EquipmentTemplate> = {
    version: "1.0.0",
    lastUpdated: Date.now(),
    data: bloodKnightWeapons,
    metadata: {
        author: "Game Design Team",
        description: "血骑士职业装备配置，包含武器和护甲",
        changelog: [
            "1.0.0 - 初始版本，包含基础武器和护甲配置"
        ]
    }
};

// 导出便于其他模块使用的查询函数
export const BloodKnightEquipmentHelper = {
    /**
     * 获取所有血骑士武器
     */
    getWeapons: () => bloodKnightWeapons.filter(eq => eq.solt === "武器"),
    
    /**
     * 获取所有血骑士护甲
     */
    getArmors: () => bloodKnightWeapons.filter(eq => eq.solt === "护甲"),
    
    /**
     * 根据品质获取装备
     */
    getByQuality: (minQuality: number, maxQuality: number) => 
        bloodKnightWeapons.filter(eq => 
            eq.quality.min <= maxQuality && eq.quality.max >= minQuality
        ),
    
    /**
     * 获取包含特定技能的装备
     */
    getBySkill: (skillId: string) =>
        bloodKnightWeapons.filter(eq => 
            eq.skillPools.inherent.some(skill => skill.skillId === skillId) ||
            eq.skillPools.enchantable.some(pool => pool.skill.skillId === skillId)
        )
};
